package com.hilatest.wsexample.basictest.chapter1;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import org.junit.Test;

import com.hilatest.wsexample.basic.chapter1.TimeServer;

public class TimeClient {

	@Test
	public void testServer() throws Exception{
		
		URL url =new URL("http://127.0.0.1:9876/ts?wsdl");
		
		/**
		 * here need to reverse the package path
		 * the first parameter should be the attribute "targetNamespace" in the <definitions> tag
		 *            service URI
		 * the second parameter should be the attribute "name" in the <definitions> tag
		 *            service name
		 */           
		QName qname=new QName("http://chapter1.basic.wsexample.hilatest.com/","TimeServerImplService");
		
		Service service = Service.create(url,qname);
		
		TimeServer eif =service.getPort(TimeServer.class);
		
		System.out.println("Time As Elapsed:"+eif.getTimeAsElapsed());
		System.out.println("Time String:"+eif.getTimeString());
		
	}
	/**
	 * 
	 */
}
